{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Demonstration of Boostrap \n",
    "# Contact: Michael Pyrcz, University of Texas at Austin, Geostatistics Course\n",
    "#\n",
    "# Steps:\n",
    "# 1. Build an initial sample set with $ndata$ samples.\n",
    "# 2. Draw from this initial sample set, with replacement, $ndata$ times to build a new realization of the sample.  \n",
    "#    Repeat this $nreal$ times to make realizations of the sample.\n",
    "# 3. Calculate the statistic of interest for each realization. This demonstration considers with mean and variance.  \n",
    "#    We could have considered any sstatistic including median, 13th percentile, skew etc. \n",
    "# 4. - 6. Quantify and visualize uncertainty with histograms and summary statistics.\n",
    "#\n",
    "# Efron, 1982, The jackknife, the bootstrap, and other resampling plans, Society of Industrial and Applied Math, \n",
    "# CBMS-NSF Monographs, 38."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Imports \n",
    "import scipy\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import math\n",
    "import random as rand\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The initial sample set:\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([ 0.78905746, -0.74536691, -0.3672344 , -1.7200198 , -1.45637476,\n",
       "        0.596527  ,  1.26733395,  0.00919964,  1.65619443, -0.97839249])"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1. Make Dataset with User Specified Number of Data (assume Gaussian N[0,1] for this example, but could be any distribution)\n",
    "nreal = 100                                # number of bootstrap realizations\n",
    "ndata = 10                                 # number of data samples available\n",
    "data = np.zeros((ndata))                    \n",
    "for idata in range(0, ndata):\n",
    "    data[idata] = np.random.normal()\n",
    "print('The initial sample set:')\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The realizations of the sample set:\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[ 1.26733395,  0.596527  ,  0.00919964,  0.00919964,  0.00919964,\n",
       "        -0.74536691, -0.3672344 ,  0.78905746, -1.7200198 , -1.7200198 ,\n",
       "        -0.97839249,  0.596527  , -0.97839249,  1.26733395,  0.596527  ,\n",
       "         0.78905746,  1.65619443, -1.7200198 , -1.45637476, -1.7200198 ,\n",
       "         0.00919964,  1.26733395, -0.74536691, -0.3672344 ,  0.00919964,\n",
       "        -0.74536691,  0.596527  ,  1.65619443, -1.7200198 ,  0.596527  ,\n",
       "        -0.3672344 ,  0.78905746,  0.00919964,  1.26733395, -1.45637476,\n",
       "         0.00919964,  0.00919964,  0.596527  ,  0.00919964, -0.74536691,\n",
       "        -1.45637476,  1.26733395,  0.596527  , -1.45637476,  0.596527  ,\n",
       "         0.596527  ,  1.26733395,  1.26733395,  1.65619443, -0.74536691,\n",
       "         1.65619443,  0.596527  , -1.7200198 , -1.45637476, -0.97839249,\n",
       "        -0.3672344 , -0.97839249, -0.74536691, -1.7200198 , -0.3672344 ,\n",
       "         0.596527  ,  0.596527  ,  1.26733395,  1.26733395,  0.596527  ,\n",
       "         1.26733395,  0.00919964,  1.65619443, -0.74536691,  1.26733395,\n",
       "        -1.7200198 ,  1.65619443, -1.7200198 ,  1.65619443, -1.7200198 ,\n",
       "        -0.74536691, -0.74536691, -1.7200198 , -1.45637476, -0.3672344 ,\n",
       "        -0.74536691,  1.65619443, -1.45637476, -0.97839249, -0.3672344 ,\n",
       "         0.78905746,  0.596527  , -1.7200198 , -0.74536691,  0.596527  ,\n",
       "        -0.74536691, -1.45637476,  1.65619443, -0.74536691,  1.26733395,\n",
       "         1.26733395,  1.26733395, -1.45637476,  1.65619443, -0.97839249],\n",
       "       [ 0.596527  ,  0.596527  , -1.7200198 ,  1.65619443,  0.78905746,\n",
       "         0.78905746, -1.7200198 ,  1.26733395,  1.26733395,  0.78905746,\n",
       "         1.65619443, -0.74536691,  1.65619443, -1.7200198 , -0.74536691,\n",
       "        -0.3672344 , -1.45637476, -1.45637476, -0.74536691, -0.74536691,\n",
       "        -1.7200198 ,  0.596527  , -0.3672344 , -0.74536691,  0.596527  ,\n",
       "        -0.74536691, -0.3672344 ,  0.596527  , -0.3672344 , -0.74536691,\n",
       "        -0.3672344 , -0.3672344 ,  1.65619443,  0.596527  , -1.45637476,\n",
       "         0.78905746,  0.00919964, -0.3672344 ,  0.596527  , -1.7200198 ,\n",
       "         0.00919964, -1.7200198 ,  1.26733395, -1.45637476,  0.78905746,\n",
       "        -0.74536691, -0.3672344 ,  0.596527  ,  0.596527  ,  1.65619443,\n",
       "         1.65619443, -0.74536691,  0.00919964, -1.45637476, -0.74536691,\n",
       "        -1.7200198 , -1.45637476, -0.3672344 , -1.45637476,  1.65619443,\n",
       "         0.596527  ,  0.78905746, -0.74536691, -1.45637476, -0.97839249,\n",
       "         0.78905746,  1.65619443, -1.7200198 ,  1.26733395, -1.45637476,\n",
       "        -1.7200198 , -0.3672344 , -0.97839249, -0.97839249,  1.26733395,\n",
       "         0.78905746, -0.3672344 ,  1.65619443,  0.596527  , -0.74536691,\n",
       "        -0.97839249,  0.78905746, -1.45637476, -1.45637476,  0.78905746,\n",
       "         0.596527  , -0.97839249, -0.97839249, -1.45637476,  0.00919964,\n",
       "        -0.3672344 , -0.74536691, -0.97839249,  0.78905746,  1.65619443,\n",
       "        -0.97839249,  1.65619443,  1.26733395,  0.00919964, -0.74536691],\n",
       "       [-0.3672344 , -0.97839249,  0.596527  , -1.7200198 , -1.7200198 ,\n",
       "         0.78905746,  0.00919964,  0.596527  ,  1.26733395, -0.74536691,\n",
       "         1.26733395, -1.7200198 , -1.45637476,  0.596527  , -0.97839249,\n",
       "         0.78905746, -0.3672344 , -1.45637476, -0.3672344 , -0.3672344 ,\n",
       "         0.596527  ,  0.596527  ,  1.26733395, -0.74536691, -0.74536691,\n",
       "         0.00919964,  0.00919964,  0.00919964,  1.65619443, -0.3672344 ,\n",
       "         0.596527  , -0.3672344 ,  1.26733395, -0.74536691, -1.45637476,\n",
       "        -1.7200198 , -1.7200198 , -1.45637476, -1.45637476,  1.65619443,\n",
       "        -0.97839249,  0.596527  ,  0.78905746, -0.97839249, -0.3672344 ,\n",
       "        -0.3672344 ,  1.65619443, -0.74536691,  1.26733395,  0.00919964,\n",
       "         0.78905746,  0.00919964, -1.7200198 ,  1.65619443, -1.7200198 ,\n",
       "        -0.3672344 ,  1.26733395, -0.97839249,  0.596527  ,  0.596527  ,\n",
       "         0.78905746, -0.3672344 , -0.97839249,  0.596527  , -0.74536691,\n",
       "         0.00919964,  1.26733395,  1.65619443,  1.65619443, -0.74536691,\n",
       "        -0.74536691, -1.7200198 ,  0.596527  ,  0.596527  , -1.7200198 ,\n",
       "        -0.97839249, -1.45637476,  1.26733395, -1.45637476, -0.97839249,\n",
       "         1.26733395,  0.00919964,  0.78905746, -1.7200198 ,  0.596527  ,\n",
       "         1.65619443,  0.596527  ,  1.65619443,  0.78905746,  1.26733395,\n",
       "         1.26733395, -0.74536691, -1.7200198 ,  0.596527  , -0.3672344 ,\n",
       "        -0.97839249,  0.00919964, -1.7200198 ,  1.65619443,  0.78905746],\n",
       "       [ 1.65619443,  0.596527  ,  1.26733395, -0.74536691, -0.97839249,\n",
       "        -0.74536691,  0.00919964,  0.00919964, -0.97839249,  0.596527  ,\n",
       "        -1.7200198 ,  0.78905746,  0.78905746,  0.596527  ,  0.00919964,\n",
       "         1.26733395,  0.00919964, -0.97839249,  1.26733395,  0.596527  ,\n",
       "         0.596527  , -0.74536691,  1.65619443,  0.596527  ,  1.26733395,\n",
       "        -1.45637476, -0.3672344 ,  0.78905746, -0.74536691, -1.7200198 ,\n",
       "         1.26733395, -0.3672344 ,  0.00919964, -0.74536691, -0.97839249,\n",
       "        -0.74536691, -1.45637476, -0.3672344 ,  0.78905746,  0.78905746,\n",
       "        -1.7200198 ,  0.596527  , -1.7200198 ,  1.65619443,  1.26733395,\n",
       "        -1.7200198 ,  0.596527  ,  0.00919964,  1.65619443, -1.45637476,\n",
       "        -1.45637476, -0.97839249, -1.7200198 ,  1.65619443, -0.3672344 ,\n",
       "        -0.3672344 ,  0.78905746,  0.596527  ,  0.596527  ,  0.78905746,\n",
       "        -1.45637476,  1.65619443, -0.97839249, -0.74536691, -0.74536691,\n",
       "         1.65619443, -0.74536691,  0.78905746,  1.26733395, -1.7200198 ,\n",
       "         0.00919964, -0.74536691, -0.74536691,  0.00919964,  0.00919964,\n",
       "        -0.3672344 ,  0.00919964,  1.65619443, -0.74536691,  0.596527  ,\n",
       "         1.26733395,  0.78905746,  0.00919964,  0.00919964,  0.00919964,\n",
       "        -1.7200198 ,  0.596527  ,  0.78905746, -0.3672344 , -1.45637476,\n",
       "         0.78905746, -1.7200198 , -0.74536691,  1.26733395, -0.3672344 ,\n",
       "         1.26733395, -1.7200198 , -1.45637476, -0.74536691,  1.65619443],\n",
       "       [-0.74536691, -0.3672344 , -0.3672344 , -0.74536691, -1.45637476,\n",
       "        -1.45637476,  0.596527  ,  0.00919964, -0.3672344 ,  0.00919964,\n",
       "         1.26733395, -1.45637476, -0.74536691, -1.7200198 ,  0.00919964,\n",
       "        -1.45637476,  0.78905746,  0.596527  , -1.7200198 ,  1.65619443,\n",
       "         0.78905746, -1.45637476,  0.596527  ,  0.596527  ,  0.596527  ,\n",
       "         1.26733395,  0.00919964,  1.26733395, -0.74536691,  1.65619443,\n",
       "        -0.3672344 ,  1.65619443, -0.3672344 , -1.7200198 , -0.3672344 ,\n",
       "        -0.3672344 , -0.74536691,  0.596527  ,  0.00919964,  0.596527  ,\n",
       "         0.00919964, -1.45637476,  0.596527  , -1.45637476, -0.3672344 ,\n",
       "        -0.74536691, -0.3672344 ,  1.65619443, -1.45637476,  0.78905746,\n",
       "         0.78905746,  0.00919964,  1.65619443,  0.78905746, -0.97839249,\n",
       "        -1.45637476,  0.00919964, -0.97839249,  0.78905746,  0.596527  ,\n",
       "        -0.3672344 , -1.7200198 , -0.74536691,  1.26733395, -0.74536691,\n",
       "         0.00919964,  0.78905746,  0.00919964, -1.7200198 , -0.74536691,\n",
       "        -1.45637476, -0.3672344 ,  0.78905746, -0.74536691, -0.74536691,\n",
       "        -1.45637476,  0.78905746, -1.7200198 ,  0.78905746,  1.65619443,\n",
       "         1.65619443,  1.65619443, -1.7200198 , -0.3672344 ,  0.596527  ,\n",
       "         0.78905746,  0.78905746, -0.97839249,  0.00919964,  0.00919964,\n",
       "         0.78905746, -1.45637476, -0.3672344 ,  0.00919964,  1.65619443,\n",
       "        -1.45637476, -1.7200198 ,  0.00919964, -0.3672344 ,  0.596527  ],\n",
       "       [-0.97839249,  1.65619443, -1.7200198 ,  0.78905746,  1.26733395,\n",
       "        -1.7200198 ,  1.65619443, -0.74536691, -1.7200198 ,  0.00919964,\n",
       "        -0.3672344 , -0.97839249, -0.97839249,  1.26733395, -0.3672344 ,\n",
       "         0.596527  , -1.45637476, -0.3672344 , -1.45637476, -1.45637476,\n",
       "         1.26733395, -0.74536691,  0.00919964,  1.26733395,  0.596527  ,\n",
       "        -0.3672344 ,  0.78905746, -1.45637476, -0.97839249, -0.97839249,\n",
       "         0.00919964, -0.3672344 , -1.7200198 ,  0.596527  ,  0.78905746,\n",
       "        -0.74536691, -0.3672344 ,  1.65619443,  0.00919964,  0.78905746,\n",
       "         0.00919964,  1.65619443, -1.45637476,  0.00919964,  0.596527  ,\n",
       "         0.00919964,  1.65619443, -0.74536691,  1.65619443, -0.3672344 ,\n",
       "        -0.74536691, -0.74536691,  0.00919964, -0.3672344 ,  1.26733395,\n",
       "        -0.74536691,  1.26733395,  0.00919964,  0.596527  , -0.97839249,\n",
       "        -0.97839249,  1.26733395,  1.26733395, -0.74536691, -0.97839249,\n",
       "        -1.7200198 , -1.7200198 , -1.45637476,  1.26733395, -0.74536691,\n",
       "        -0.97839249,  0.00919964, -1.7200198 , -0.74536691,  0.00919964,\n",
       "        -1.45637476, -0.3672344 ,  0.00919964,  0.596527  ,  1.65619443,\n",
       "         0.78905746,  1.26733395,  1.65619443,  0.78905746,  1.65619443,\n",
       "        -0.3672344 ,  1.65619443,  1.65619443,  1.65619443, -0.3672344 ,\n",
       "        -1.45637476, -0.74536691,  1.26733395, -1.45637476, -0.97839249,\n",
       "         1.65619443,  0.596527  ,  1.26733395, -1.7200198 ,  0.596527  ],\n",
       "       [-1.7200198 ,  0.596527  ,  0.00919964,  1.26733395,  1.26733395,\n",
       "        -1.7200198 , -0.97839249, -0.3672344 ,  0.00919964,  0.00919964,\n",
       "        -0.3672344 , -1.7200198 , -0.74536691,  0.596527  , -1.45637476,\n",
       "         0.00919964,  0.00919964,  0.78905746,  0.596527  ,  1.65619443,\n",
       "         0.78905746, -0.97839249,  0.596527  , -1.45637476,  0.00919964,\n",
       "         0.596527  ,  0.596527  ,  0.78905746, -0.74536691, -0.74536691,\n",
       "         1.65619443,  0.00919964, -0.3672344 ,  1.26733395,  0.00919964,\n",
       "        -0.74536691,  1.65619443,  0.78905746, -1.7200198 , -1.45637476,\n",
       "        -1.7200198 , -1.7200198 ,  0.78905746, -1.45637476, -1.45637476,\n",
       "         0.00919964,  1.65619443, -0.3672344 , -0.3672344 ,  0.78905746,\n",
       "        -0.97839249,  1.65619443,  1.26733395, -0.74536691, -1.45637476,\n",
       "        -1.7200198 , -1.7200198 ,  1.26733395,  0.78905746,  0.596527  ,\n",
       "        -0.3672344 , -1.45637476, -0.97839249, -1.45637476, -1.7200198 ,\n",
       "         1.65619443,  0.596527  , -0.3672344 ,  0.00919964,  0.00919964,\n",
       "         1.26733395,  0.596527  ,  0.78905746,  1.65619443, -0.74536691,\n",
       "         0.78905746,  1.65619443,  1.65619443,  0.78905746, -0.74536691,\n",
       "        -0.3672344 ,  1.65619443, -1.7200198 , -1.45637476,  1.65619443,\n",
       "        -0.3672344 , -0.74536691,  0.00919964,  0.78905746,  0.596527  ,\n",
       "         1.65619443,  0.78905746, -0.97839249, -0.97839249, -0.74536691,\n",
       "         1.65619443, -1.7200198 , -0.3672344 , -1.45637476,  0.596527  ],\n",
       "       [-0.74536691,  0.596527  ,  0.596527  ,  1.26733395, -0.3672344 ,\n",
       "        -0.74536691,  1.65619443,  0.78905746, -0.3672344 , -0.74536691,\n",
       "         1.65619443,  1.26733395, -0.97839249,  0.78905746,  1.65619443,\n",
       "        -0.97839249,  1.65619443,  0.00919964, -0.97839249, -1.45637476,\n",
       "         0.00919964,  1.65619443,  0.78905746,  1.65619443, -0.3672344 ,\n",
       "        -0.3672344 , -0.74536691,  0.00919964, -1.45637476,  1.65619443,\n",
       "        -0.74536691, -1.7200198 , -0.97839249, -0.74536691, -0.3672344 ,\n",
       "         1.65619443, -0.3672344 ,  0.78905746,  1.65619443,  1.65619443,\n",
       "         0.78905746, -1.7200198 ,  1.26733395,  1.26733395,  1.26733395,\n",
       "        -1.45637476, -0.74536691, -1.7200198 ,  1.65619443,  0.00919964,\n",
       "         1.26733395,  0.596527  , -0.3672344 ,  0.00919964, -0.97839249,\n",
       "         0.596527  , -0.97839249,  0.78905746,  0.00919964,  1.26733395,\n",
       "        -0.97839249, -0.74536691, -1.45637476, -0.74536691, -0.3672344 ,\n",
       "         0.78905746,  1.26733395,  1.65619443, -0.3672344 , -1.7200198 ,\n",
       "         1.26733395,  1.65619443,  0.78905746,  0.78905746, -0.74536691,\n",
       "         0.596527  , -0.3672344 ,  0.596527  , -1.45637476, -0.97839249,\n",
       "         0.00919964, -0.74536691,  0.596527  , -1.45637476, -0.3672344 ,\n",
       "         0.78905746, -1.7200198 ,  1.26733395, -1.45637476,  0.596527  ,\n",
       "        -1.45637476,  0.00919964, -1.7200198 ,  1.26733395,  1.26733395,\n",
       "         1.65619443,  0.00919964,  0.78905746, -1.45637476, -1.45637476],\n",
       "       [-1.45637476, -0.74536691, -0.97839249, -0.74536691, -0.74536691,\n",
       "        -0.74536691, -1.45637476,  1.65619443,  0.00919964, -1.45637476,\n",
       "         0.596527  , -0.74536691,  0.00919964, -1.7200198 , -0.74536691,\n",
       "         0.00919964,  1.65619443,  0.596527  ,  0.78905746,  0.596527  ,\n",
       "         1.26733395,  0.78905746,  0.596527  , -1.45637476,  1.26733395,\n",
       "         0.00919964, -1.7200198 , -1.7200198 , -1.45637476,  1.26733395,\n",
       "        -0.74536691, -0.74536691,  1.26733395,  0.78905746,  0.78905746,\n",
       "        -0.97839249, -1.45637476, -0.74536691, -0.3672344 , -1.7200198 ,\n",
       "        -0.74536691, -1.45637476, -1.7200198 , -1.45637476, -0.97839249,\n",
       "         0.00919964, -1.45637476, -1.45637476,  0.596527  ,  0.78905746,\n",
       "         0.596527  , -1.45637476,  1.65619443,  0.78905746, -0.97839249,\n",
       "        -1.7200198 , -0.3672344 ,  0.596527  ,  1.26733395,  0.78905746,\n",
       "        -1.7200198 , -0.97839249,  1.26733395,  1.65619443, -0.74536691,\n",
       "        -1.7200198 ,  1.26733395,  1.65619443,  1.26733395,  0.00919964,\n",
       "        -0.97839249, -1.7200198 , -1.45637476,  0.596527  ,  1.65619443,\n",
       "         0.78905746, -1.7200198 ,  0.78905746, -1.7200198 , -1.7200198 ,\n",
       "        -0.97839249, -0.3672344 ,  1.26733395,  1.65619443, -1.45637476,\n",
       "         0.596527  ,  0.596527  ,  1.65619443,  0.596527  , -1.45637476,\n",
       "        -0.74536691, -1.45637476,  0.78905746, -1.7200198 , -1.7200198 ,\n",
       "         0.78905746, -0.3672344 , -0.3672344 ,  0.00919964,  0.596527  ],\n",
       "       [ 0.78905746, -0.74536691,  0.78905746, -0.74536691,  1.26733395,\n",
       "        -0.3672344 ,  0.00919964, -0.74536691, -1.7200198 ,  0.596527  ,\n",
       "         0.596527  , -0.3672344 , -0.3672344 ,  0.00919964, -1.45637476,\n",
       "        -0.74536691, -1.45637476, -1.7200198 , -0.74536691,  0.78905746,\n",
       "        -0.74536691, -0.97839249, -0.74536691,  0.78905746,  1.26733395,\n",
       "        -1.7200198 ,  0.00919964, -0.74536691, -0.97839249, -0.74536691,\n",
       "        -0.97839249,  1.65619443, -0.74536691,  0.78905746,  0.596527  ,\n",
       "         1.65619443,  1.26733395, -0.3672344 ,  1.26733395,  1.65619443,\n",
       "        -1.45637476, -0.74536691, -1.45637476,  1.65619443, -0.97839249,\n",
       "        -1.7200198 ,  0.78905746,  0.00919964,  1.65619443, -1.45637476,\n",
       "        -0.97839249,  1.65619443, -0.3672344 ,  0.596527  ,  1.26733395,\n",
       "        -1.7200198 , -1.45637476,  0.596527  , -0.97839249, -0.97839249,\n",
       "        -1.45637476, -1.7200198 , -1.7200198 ,  0.78905746,  0.00919964,\n",
       "         1.26733395,  1.65619443,  0.78905746, -1.45637476,  0.596527  ,\n",
       "        -0.74536691, -1.45637476, -0.74536691,  0.00919964,  0.596527  ,\n",
       "         0.78905746, -0.74536691,  1.26733395, -0.97839249, -0.74536691,\n",
       "        -1.7200198 ,  1.26733395,  1.26733395,  1.26733395, -1.7200198 ,\n",
       "        -1.45637476,  0.596527  , -0.3672344 ,  0.596527  , -0.97839249,\n",
       "         1.26733395, -0.97839249, -1.7200198 ,  0.78905746,  1.65619443,\n",
       "         0.00919964, -0.74536691, -0.3672344 ,  0.596527  , -1.45637476]])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2. Perform ndata random draws with replacement, nreal times.  Here we aquire the nreal realizations of the distribution of \n",
    "# ndata, samples.\n",
    "draw = np.zeros((ndata,nreal)) \n",
    "for ireal in range(0, nreal):\n",
    "    for isample in range(0, ndata):\n",
    "        draw[isample,ireal] = rand.choice(data)\n",
    "print('The realizations of the sample set:')\n",
    "draw"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The statistics of interest for each realization of the sample set:\n",
      "[ -1.70364243e-01   1.80246874e-01  -1.51782181e-01   2.87631993e-02\n",
      "  -6.67129427e-02  -6.66700148e-01  -5.85506667e-02   3.25860136e-01\n",
      "  -4.31985353e-01  -2.65741800e-01   3.60722967e-01  -5.07985667e-01\n",
      "  -3.79506890e-01  -3.75534229e-03  -3.47798951e-01  -8.69934163e-03\n",
      "   1.03968134e-01  -5.70710492e-01  -4.81621163e-01  -4.50870316e-02\n",
      "   2.85884938e-01   1.74628855e-04   3.65339827e-01   1.34922096e-02\n",
      "   4.49738081e-01  -3.51933695e-01  -1.19014513e-01   1.19480810e-01\n",
      "  -7.53669499e-01  -1.25497597e-02  -4.15744790e-03   1.76321649e-02\n",
      "   3.10136079e-03   1.34971628e-01  -3.89814402e-01  -1.19110145e-01\n",
      "  -3.17067738e-01   1.12391847e-01   7.93082788e-02   1.50144393e-01\n",
      "  -7.25989215e-01  -4.70159347e-01  -1.04695233e-01  -3.67134385e-01\n",
      "   3.69150812e-02  -6.13025666e-01   4.68529123e-01  -1.49590812e-01\n",
      "   8.91775094e-01   1.64152470e-03   2.59583808e-01   5.98341087e-02\n",
      "  -1.29640612e-01   1.47087958e-01  -5.66789793e-01  -9.58699709e-01\n",
      "  -3.62386372e-01   7.85785767e-02   4.89442446e-02   3.96720492e-01\n",
      "  -5.34191165e-01  -2.67829533e-01  -3.80030400e-01   4.27596535e-02\n",
      "  -6.41978016e-01   4.00353134e-01   6.04378809e-01   4.66846331e-01\n",
      "   2.44573398e-01  -5.25025486e-01  -5.80006562e-01  -2.45813457e-01\n",
      "  -4.40184130e-01   2.84377331e-01  -2.13768566e-01  -1.25098650e-01\n",
      "  -3.31438005e-01   5.45799568e-01  -5.04173457e-01  -2.37122403e-01\n",
      "   1.99713337e-02   7.97796443e-01  -7.67142716e-02  -3.71298551e-01\n",
      "   1.39283659e-01   1.30555743e-01   1.98410770e-01   2.99013516e-01\n",
      "   4.11212152e-02  -1.18306218e-01   9.98259495e-02  -8.50538020e-01\n",
      "  -4.51685986e-01  -1.81644516e-02   3.32500319e-01   4.88834855e-01\n",
      "  -2.73420606e-01  -2.40154755e-01  -1.81805549e-01   1.94850973e-02] [ 1.23200839  0.64005696  0.97192761  1.17504292  1.21237765  0.71954446\n",
      "  1.19793851  0.61345089  1.14487049  0.68190067  1.22941512  1.02453174\n",
      "  0.81642093  1.37777637  0.83346641  0.69753278  1.52415707  0.93283847\n",
      "  0.96687817  1.46908881  0.78660902  1.08300904  0.59506179  1.11696552\n",
      "  0.45538982  0.71839372  0.49766721  1.14426632  0.79794062  1.31636614\n",
      "  0.71778504  1.01590317  1.06963378  0.96121931  0.76716562  1.16840806\n",
      "  1.13697822  0.76547556  1.0479284   1.81981099  0.7024077   1.65233372\n",
      "  1.52185632  1.73066925  0.88381974  0.58820621  1.15646575  1.08068553\n",
      "  1.03359846  0.95434452  1.26104286  1.03514399  1.60693243  1.18032516\n",
      "  0.95986999  0.60798482  1.1771616   0.58395557  0.99317687  0.71373654\n",
      "  0.78654475  1.42958934  1.24365697  1.28241933  0.34646916  1.42577332\n",
      "  1.11442092  1.52521297  1.4339373   0.89103106  1.09118902  1.41009043\n",
      "  1.0392418   0.80801207  1.18318108  0.85795341  0.88623873  1.5357716\n",
      "  1.02493777  1.19540825  1.21373632  0.70121599  1.70339318  1.40068489\n",
      "  1.19755636  1.05012737  0.92224375  1.45715137  0.96155552  0.78680422\n",
      "  1.25888814  0.53340649  1.44118657  1.14024429  1.507666    1.3709843\n",
      "  1.35233781  1.08633302  1.34023971  1.05400514]\n"
     ]
    }
   ],
   "source": [
    "# 3. Calculate summary statistic - average and variance\n",
    "mean = np.zeros((nreal))\n",
    "var = np.zeros((nreal))\n",
    "for ireal in range(0, nreal):\n",
    "    s = 0.0\n",
    "    ss = 0.0\n",
    "    count = 0.0\n",
    "    for isample in range(0, ndata):\n",
    "        s = s + draw[isample,ireal]\n",
    "        ss = ss + draw[isample,ireal] * draw[isample,ireal]\n",
    "        count = count + 1.0\n",
    "    mean[ireal] = s / count \n",
    "    var[ireal] = ss / count - mean[ireal] * mean[ireal]\n",
    "print('The statistics of interest for each realization of the sample set:')\n",
    "print(mean,var)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAEWCAYAAAB1xKBvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHRtJREFUeJzt3XucHGWd7/HPlxBEIAQhQ7iEEFQOS5SLOAbloIQ9wknA\nGDnqmhxEQTCiZhX3yDGuvoBd1z24rusF0BAxi0EBXSUQIYDgCrjyQhIQgXDREMIm4ZJwDQGWGPid\nP+oZLTo9M0/PdHX3ZL7v16tfU/Vcun5d1TO/qaeqn1ZEYGZm1p+t2h2AmZkNDU4YZmaWxQnDzMyy\nOGGYmVkWJwwzM8vihGFmZlmcMMyGMEknSvqPFm/zOEmrJG2Q9KZWbtvaywnDkLRS0gvpD8BTkq6S\ntFcTnneCpJC0dWb7kPT6wW43l6TJkl5Or/tZSfdLOqlV2x/C/hmYHRE7RMRvayvTcVxbPu6SRqYy\nf/BrCHPCsB7TImIHYHfgMeCcNsezmdzE06CH0+veEfgM8F1J+1WwnS3J3sCyfto8BUwtrU9NZTaE\nOWHYK0TEfwE/ASb2lEkaLWmBpHWSHpL0RUlbpbqt0vpD6T/IBZJGp643pZ9Pp//i3ybp9ZJulPSM\npMcl/Sg9T0/b36W2H0hnAKslfU7So8C/SnqNpCtTLE+l5XGlWG+Q9P8k3SppvaQrJO2c8bojIhYD\nTwIHlp7vLyRdJ+nJdAbyV6W6YyTdk85O1kj6bCrPifEfJN2cXuvPJO0i6Ycp5iWSJpTah6RPSVqR\n9tlXe/Z/rYHEW+c56h5TSa+StAEYkY7TA33s0ouAD5XWPwQsqNnOaEnfk/RIiucfJI1Ida+T9O+S\nnkiv+YeSdir1XSnps5LuTO+lH0nato94rBkiwo9h/gBWAu9My9sB3wcWlOoXAFcAo4AJwO+Bk1Pd\nR4DlwGuBHYDLgItS3QQggK1Lz3UJ8AWKf1a2BQ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MAxVBWT/kuwC+APwDXAztXEGPdbdSJcXuKN//omv4XAXcBd1K8OXdvR4wUd4b8\nLj2WdeJ+pBhGibSv7kiPY6rej/XeX8CpwKlpWRRfEvZAiqG7r74V/a70F+MFwFOl/ba0v+Pehhhn\npxh+R3Fh/rBO249p/UTg0pp+LduPzXp4ahAzM8syXIekzMysQU4YZmaWxQnDzMyyOGGYmVkWJwwz\nM8vihGHWABUz3/7PmrLTJH2njz4bqo/MrHpOGGaNuYTiw1ll9eb6MtviOGGYNeYnwLHpU709Exru\nAfxW0i8k3Z6+32CzGUtVfHfDlaX1cyWdmJbfLOnGNAndtTWfQjfrCE4YZg2IYuK4Wynm+ILi7OLH\nwAvAcRFxCHAk8LWeKSv6k+a6Ogd4X0S8GZgPfLnZsZsN1pCcfNCszXqGpa5IP0+mmOrjHyW9A3iZ\nYorrsRTTrvdnP+CNFLOVQvGlPI/02cOsDZwwzBp3BfB1FV+rul1E3JaGlrqAN0fEHyWtBLat6beJ\nV57V99QLWBYRb6s2bLPB8ZCUWYMiYgPwS4qho56L3aOBtSlZHAnsXafrQ8BESa+StBPFNykC3A90\nSXobFENUpS8CMusYPsMwG5hLgIX8+Y6pHwI/k3QXsBS4r7ZDRKyS9GOKKawfBH6byjdKeh/wrTQN\n9tbANyhmMDXrGJ6t1szMsnhIyszMsjhhmJlZFicMMzPL4oRhZmZZnDDMzCyLE4aZmWVxwjAzsyz/\nH2bgaUMkwe4BAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1b1bcd9acf8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAEWCAYAAAB1xKBvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHU9JREFUeJzt3XuYHVWZ7/Hvj4RbIBAgLZeQ0KAMGpVLaC4qaMDLkIAi\nM4zAIDc5BhAUZjxnyKgP+Mwc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X9dMO0VSw24uJC1vfmRmzeeEYdY30yhuPiw7NE03W605YZj1zZXA/umudSS1A1sB\nf5B0m6QH0vMo3tO7cXq+wm9K4+dKOjoN7yrpztTR3c2t7gnXLIcThlkfRMQLFH31TEiTDgWuAF4H\nDoqIccA+wFnK7FlP0trAORTPhdgVmAqcMdCxm60sdw1i1nfdzVLXpb/HUnTN8G+SPknRlcQoYHPg\nmYzl7QB8hKK3USi6UBlU/VSZgROGWX9cB/wwPaZ1WETMSk1LbcCuEfGmpIXAejXzdbHiUX13uYC5\nEfGx5oZttnLcJGXWRxGxHLidoumo+2T3xsDSlCz2AbapM+uTwFhJ60oaQeppFJgHtEn6GBRNVJI+\n3NQ3YdYPPsIw659pwDW8e8XUpcANqefQmcBjtTNExFOSrgDmAE8Af0jT35B0MHC2pI0p9ssfAXOb\n/i7M+sC91ZqZWRY3SZmZWRYnDDMzy+KEYWZmWZwwzMwsixOGmZllccIwM7MsThhmZpbl/wOK68lq\nevhjSAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1b1bcd9aef0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 4. Visualize the summary statistic, calculate the variance or any other measure of spread to represent uncertainty in\n",
    "#    the summary statistic.\n",
    "plt.hist(mean,bins=20,normed=True)\n",
    "plt.title(\"Bootstrap Resamples of Mean\")\n",
    "plt.xlabel(\"Value\")\n",
    "plt.ylabel(\"Frequency\")\n",
    "plt.show()\n",
    "\n",
    "plt.hist(var)\n",
    "plt.title(\"Bootstrap Resamples of Variance\")\n",
    "plt.xlabel(\"Value\")\n",
    "plt.ylabel(\"Frequency\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>-0.080045</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.359072</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>-0.958700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>-0.354547</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>-0.031626</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>0.131660</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>0.891775</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             mean\n",
       "count  100.000000\n",
       "mean    -0.080045\n",
       "std      0.359072\n",
       "min     -0.958700\n",
       "25%     -0.354547\n",
       "50%     -0.031626\n",
       "75%      0.131660\n",
       "max      0.891775"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 5. Summary statistics to describe uncertainty in the mean from bootstrap\n",
    "columns = ['mean']\n",
    "df_mean = pd.DataFrame(mean,columns=columns)\n",
    "df_mean.describe()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>var</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>1.068578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.313462</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.346469</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>0.814319</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>1.075160</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>1.259427</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>1.819811</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              var\n",
       "count  100.000000\n",
       "mean     1.068578\n",
       "std      0.313462\n",
       "min      0.346469\n",
       "25%      0.814319\n",
       "50%      1.075160\n",
       "75%      1.259427\n",
       "max      1.819811"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 6. Summary statistics to describe uncertainty in the variance from bootstrap\n",
    "columns = ['var']\n",
    "df_var = pd.DataFrame(var,columns=columns)\n",
    "df_var.describe()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# What did we learn?\n",
    "# 1. Uncertainty decreases rapidly as the number of samples increases.\n",
    "# 2. Bootstrap result for uncertainty in the mean is the same as standard error.\n",
    "# 3. Bootstrap provides uncertainty in any statistic.\n",
    "# 4. Bootstrap does not account for spatial context, location of data, local nonstationarity, spatial correlation etc."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
